package com.yj.springbootmybatis.util;

import lombok.Data;

@Data
public class ResponseUtil<T> {


    private Integer code;
    private String message;
    private T data;
    private Long timestamps;

    public ResponseUtil(){}


   public static ResponseUtil success(){
       ResponseUtil<Object> responseUtil = new ResponseUtil<>();
       responseUtil.setCode(200);
       responseUtil.setMessage("success");
       responseUtil.setTimestamps(System.currentTimeMillis()/1000);
       return responseUtil;
   }

   public static ResponseUtil error(){
       ResponseUtil<Object> responseUtil = new ResponseUtil<>();
       responseUtil.setCode(10000);
       responseUtil.setMessage("failure");
       responseUtil.setTimestamps(System.currentTimeMillis()/1000);
       return responseUtil;
   }

   public ResponseUtil<T> code(Integer code){
        this.code = code;
       return this;
   }

   public ResponseUtil<T> message(String message){
        this.message = message;
        return this;
   }

   public ResponseUtil<T> data(T data){
        this.data = data;
        return this;
   }




}
